﻿using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEditor;

public class TinyWndMenu : MonoBehaviour
{

    [MenuItem("TinyWnd/NodePath", false, 0)]
    static public void NodePath()
    {
        Transform[] arr = Selection.transforms;
        if (arr.Length == 0)
            return;

        var path = new List<string>();
        Transform tran = arr[0];
        while (tran != null && tran.GetComponent<UIPanel>() == null ||
               tran.parent != null && tran.parent.name != "UI Root")
        {
            path.Insert(0, tran.name);
            tran = tran.parent;
        }

        var sb = new StringBuilder();
        foreach (var n in path)
        {
            if (sb.Length > 0)
                sb.Append("/");
            sb.Append(n);
        }
        Debug.Log(sb);
    }
}
